﻿Public Class NewCustomer

    Private Sub BtnClose_Click(sender As System.Object, e As System.EventArgs) Handles BtnClose.Click
        Me.Close()
    End Sub

    Private Sub BtnAddNew_Click(sender As System.Object, e As System.EventArgs) Handles BtnAddNew.Click
        Dim values As New Dictionary(Of String, String)

        If TxtCustomerName.Text.Length < 1 Or TxtCustomerSurname.Text.Length < 1 Or TxtCustomerTown.Text.Length < 1 Or TxtCustomerPostcode.Text.Length < 1 Or TxtCustomerAddress1.Text.Length < 1 Or TxtCustomerMobile.Text.Length < 1 Then
            MsgBox("All fields are required")
        Else
            values.Add("name", TxtCustomerName.Text)
            values.Add("surname", TxtCustomerSurname.Text)
            values.Add("mobile", TxtCustomerMobile.Text)
            values.Add("home_tel", TxtCustomerHome.Text)
            values.Add("town", TxtCustomerTown.Text)
            values.Add("postcode", TxtCustomerPostcode.Text)
            values.Add("line1", TxtCustomerAddress1.Text)
            values.Add("line2", TxtCustomerAddress2.Text)

            Dim databaseProvider As DatabaseProvider = databaseProvider.Instance()
            databaseProvider.InsertCustomer(values)
        End If

    End Sub
End Class